package com.fuze.energy.common;

import lombok.Getter;
import lombok.ToString;

/**
 * @author sepc_
 * @date 3/16/2021 13:52
 * 自定义异常
 */
@ToString
public class CustomException extends RuntimeException {
    private static final long serialVersionUID = -8328016203444738061L;

    /**
     * 错误码
     */
    @Getter
    private Integer code;

    /**
     * 错误信息
     */
    @Getter
    private String message;

    /**
     * 私有化的无参构造器
     */
    private CustomException() {
    }

    /**
     * 用于创建自定义异常，但是必须在枚举类里面先先声明
     */
    public CustomException(Advice advice) {
        this.code = advice.getCode();
        this.message = advice.getMessage();
    }
}
